/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.sac.be;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Colao
 */
@Entity
@Table(name = "SAC_CREDITO")
@NamedQueries({@NamedQuery(name = "Credito.findAll", query = "SELECT c FROM Credito c"), @NamedQuery(name = "Credito.findByIdCredito", query = "SELECT c FROM Credito c WHERE c.idCredito = :idCredito"), @NamedQuery(name = "Credito.findByFechaRegistro", query = "SELECT c FROM Credito c WHERE c.fechaRegistro = :fechaRegistro"), @NamedQuery(name = "Credito.findByMontoTotal", query = "SELECT c FROM Credito c WHERE c.montoTotal = :montoTotal"), @NamedQuery(name = "Credito.findByFechaInicio", query = "SELECT c FROM Credito c WHERE c.fechaInicio = :fechaInicio"), @NamedQuery(name = "Credito.findByFechaFin", query = "SELECT c FROM Credito c WHERE c.fechaFin = :fechaFin")})
public class Credito implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_CREDITO")
    private Long idCredito;
    @Column(name = "FECHA_REGISTRO")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaRegistro;
    @Column(name = "MONTO_TOTAL")
    private Double montoTotal;
    @Column(name = "FECHA_INICIO")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaInicio;
    @Column(name = "FECHA_FIN")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaFin;
    @OneToMany(mappedBy = "fidSacCredito", fetch = FetchType.LAZY)
    private List<SolicitudCredito> solicitudCreditoCollection;
    @OneToMany(mappedBy = "fidSacCredito", fetch = FetchType.LAZY)
    private List<CuotaCredito> cuotaCreditoCollection;

    public Credito() {
    }

    public Credito(Long idCredito) {
        this.idCredito = idCredito;
    }

    public Long getIdCredito() {
        return idCredito;
    }

    public void setIdCredito(Long idCredito) {
        this.idCredito = idCredito;
    }

    public Date getFechaRegistro() {
        return fechaRegistro;
    }

    public void setFechaRegistro(Date fechaRegistro) {
        this.fechaRegistro = fechaRegistro;
    }

    public Double getMontoTotal() {
        return montoTotal;
    }

    public void setMontoTotal(Double montoTotal) {
        this.montoTotal = montoTotal;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public List<SolicitudCredito> getSolicitudCreditoCollection() {
        return solicitudCreditoCollection;
    }

    public void setSolicitudCreditoCollection(List<SolicitudCredito> solicitudCreditoCollection) {
        this.solicitudCreditoCollection = solicitudCreditoCollection;
    }

    public List<CuotaCredito> getCuotaCreditoCollection() {
        return cuotaCreditoCollection;
    }

    public void setCuotaCreditoCollection(List<CuotaCredito> cuotaCreditoCollection) {
        this.cuotaCreditoCollection = cuotaCreditoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCredito != null ? idCredito.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Credito)) {
            return false;
        }
        Credito other = (Credito) object;
        if ((this.idCredito == null && other.idCredito != null) || (this.idCredito != null && !this.idCredito.equals(other.idCredito))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.sac.be.Credito[idCredito=" + idCredito + "]";
    }

}
